<template>
    <div class="articles">
        <banner></banner>
        <div class="site-content animate">
            <!-- 文章目录 -->
            <!--<div id="article-menus">-->
                <!--<menu-tree :menus="menus" child-label="child"></menu-tree>-->
            <!--</div>-->
            <main class="site-main">
                <article class="hentry">
                    <!-- 文章头部 -->
                    <header class="entry-header">
                        <!-- 标题输出 -->
                        <h1 class="entry-title">{{blogDetails.title}}</h1>
                        <hr>
                        <div class="breadcrumbs">
                            <div id="crumbs" style="color: #ff938b">最后更新时间：{{blogDetails.lastTime}}</div>
                          <p style="color: #28dfff;font-family: 'Century Schoolbook',serif;position: absolute;margin-left: 450px;margin-top: -20px">——— 喜欢的东西,要和懂它的人分享才有意义。</p>
                        </div>
                    </header>
                    <!-- 正文输出 -->
                    <div class="entry-content" v-for="item in blogDetails.contentDtoList">

                        <h4>{{item.blogDetailsPojo.entry}}</h4>

                        <p v-if="item.blogDetailsPojo.type==='content'">{{item.blogDetailsPojo.content}}</p>
                        <ul v-if="item.blogDetailsPojo.type==='classify'" v-for="classify in item.classifyList">
                          <li>{{classify}}</li>
                        </ul>
                      <el-image
                          v-if="item.blogDetailsPojo.type==='img'"
                          style="width: 900px; height: 500px"
                          :src="item.blogDetailsPojo.content"
                          fit="contain"></el-image>
                      <div v-if="item.isContain">
                        <el-image
                            v-if="item.containType==='img'"
                            style="width: 800px; height: 300px"
                            :src="item.containContent"
                            fit="contain"></el-image>
                        <code v-if="item.containType==='code'">{{item.containContent}}</code>
                      </div>
                      <pre v-if="item.blogDetailsPojo.type==='code'"><code>{{item.blogDetailsPojo.content}}</code></pre>
                      <blockquote v-if="item.blogDetailsPojo.type==='important'">
                        <p>&nbsp;&nbsp;{{item.blogDetailsPojo.content}}</p>
                      </blockquote>
                        <div v-if="item.blogDetailsPojo.type==='entry_classify'" v-for="entry in item.entryClassifyList">
                        <ol>

                            <li>{{entry.entry}}
                                <blockquote>
                                    <p>{{entry.content}}</p>
                                </blockquote>
                            </li>
                        </ol>
                        <!--<hr>-->
                        </div>
                      <hr>
                        <!--<hr>-->

                        <!--<h4>安装成功验证</h4>-->

                        <!--<blockquote>-->
                            <!--<p>执行<code>lua -v</code>,出现如下信息代表安装成功<br/>-->
                                <!--Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio</p>-->
                        <!--</blockquote>-->
                        <!--<pre><code>lua -v</code></pre>-->

                    </div>
                    <!-- 文章底部 -->
                    <section-title>
                        <footer class="post-footer">
                            <!-- 阅读次数 -->
                            <div class="post-like">
                                <i class="iconfont iconeyes"></i>
                                <span class="count">{{blogDetails.viewCount}}</span>
                            </div>
                          <!-- 点赞,踩按钮 -->
                          <div style="margin-left: 550px;margin-top: -5px">
                            <v-btn
                                class="ma-2"
                                text
                                icon
                                color="blue lighten-2"
                                @click="thumb('praise')"
                            >
                              <v-icon>mdi-thumb-up</v-icon>
                            </v-btn>
                            <span class="count" style="margin-left: -16px;position: absolute;margin-top: 15px;color: #a2c7ea">{{blogDetails.praiseCount}}</span>

                            <v-btn
                                class="ma-2"
                                text
                                icon
                                color="red lighten-2"
                                @click="thumb('dislike')"
                            >
                              <v-icon>mdi-thumb-down</v-icon>
                            </v-btn>
                            <span class="count" style="margin-left: -14px;position: absolute;margin-top: 15px;color: #ea788e">{{blogDetails.dislikeCount}}</span>
                          </div>
                            <!-- 赞助按钮 -->
                            <div style="margin-top: -40px" class="donate" @click="showDonate=!showDonate">
                                <span>赏</span>
                                <ul class="donate_inner" :class="{'show':showDonate}">
                                    <li class="wedonate"><img src="http://cdn.fengziy.cn/gblog/wexin_pay.png"><p>微信</p></li>
                                    <li class="alidonate"><img src="http://cdn.fengziy.cn/gblog/ali_pay.jpg"><p>支付宝</p></li>
                                </ul>
                            </div>
                            <!-- 文章标签 -->
                            <div style="margin-top: -35px;margin-left: 80px" class="post-tags">
                                <i class="iconfont iconcategory"></i>
                                <router-link to="/category/web">Java</router-link>
                            </div>
                          <!-- 收藏按钮 -->
                          <!--<div style="margin-left: 490px;margin-top: -43px">-->
                            <!--<v-btn-->
                                <!--icon-->
                                <!--color="pink"-->
                            <!--&gt;-->
                              <!--<v-icon>mdi-heart</v-icon>-->
                            <!--</v-btn>-->
                            <!--<div style="margin-left: 30px;margin-top: -29px" >-->
                            <!--<span class="count">685</span>-->
                            <!--</div>-->
                          <!--</div>-->
                        </footer>
                    </section-title>

                    <!--声明-->
                    <div class="open-message">
                      <center><p style="color: #FE4365">版权声明</p></center>
                        <p>声明：若兮博客|版权所有，违者必究|如未注明，均为原创|本网站采用<a href="https://creativecommons.org/licenses/by-nc-sa/3.0/" target="_blank">BY-NC-SA</a>协议进行授权</p>
                        <p>转载：转载请注明原文链接 - <a href="/">{{blogDetails.title}}</a> - 若兮开发团队</p>
                    </div>
                    <!--评论-->
                  <div style="margin-bottom: 50px">
                    <comment-message-editor :inline="true" buttonText="提交" title="快来发一条评论吧..." content="快来发一条评论吧"></comment-message-editor>
                  </div>
                    <div class="comments">
                        <!--<comment v-for="item in comments" :key="item.comment.id" :comment="item.comment">-->
                            <!--<template v-if="item.reply.length">-->
                                <!--<comment v-for="reply in item.reply" :key="reply.id" :comment="reply"></comment>-->
                            <!--</template>-->
                        <!--</comment>-->
                      <center><h3 style="margin-bottom: 50px">留言评论服务正在努力上线中...</h3></center>
                    </div>
                </article>
            </main>
        </div>
    </div>
</template>

<script>
    import Banner from '@/components/banner'
    import sectionTitle from '@/components/section-title'
    import comment from '@/components/comment'
    import menuTree from '@/components/menu-tree'
		import commentMessageEditor from 'comment-message-editor'
    import {fetchComment} from '../api'
    export default {
        name: 'articles',
        data(){
          return{
              showDonate: false,
              src: 'https://ruoqing-img.oss-cn-chengdu.aliyuncs.com/web_img/blog_introduce/jhun.jpeg',
              comments: [],
              menus: [],
              blogId: 0,
              blogDetails: {
								viewCount: 0,
								praiseCount: 0,
								dislikeCount: 0,
								lastTime: '',
								title: '',
								contentDtoList: [{
									id: 0,
									blogDetailsPojo: {
										entry: '',
										content: '',
										type: ''
                  },
									classifyList: [],
									entryClassifyList:[{
										entry: '',
										content: '',
										type: ''
                  }
                  ],
									isContain: false,
									containContent: '',
									containType: ''
                }]
              }
          }
        },
        components: {
            Banner,
            sectionTitle,
            comment,
            menuTree,
					  commentMessageEditor
        },
        methods: {
          getComment(){
              fetchComment().then(res => {
                  this.comments = res.data || []
              }).catch(err => {
                  console.log(err)
              })
          },
          getBlogDetails(){
						var vm = this
						vm.axios({
							method: 'GET',
							url: this.GLOBAL.baseURL + 'blog/details/'+vm.blogId,
						}).then(function (resp) {
							if (resp.data.status === 'ok') {
								vm.blogDetails = resp.data.msg
							} else {
								vm.$message({
									message: '获取该文章信息失败!',
									type: 'error',
									center: true
								});
							}
						})
          },
					thumb(type){
						var vm = this
						vm.axios({
							method: 'PUT',
							url: this.GLOBAL.baseURL + 'blog/thumb/'+type,
              params:{blogId: vm.blogId}
						}).then(function (resp) {
							if (resp.data.status === 'ok') {
								vm.$message({
									message: resp.data.message,
									type: 'success',
									center: true
								});
								if (type === 'praise') {
									vm.blogDetails.praiseCount += 1
								} else {
									vm.blogDetails.dislikeCount += 1
                }
							}else if (resp.status === 401){
								vm.$message({
									message: '请先登录再评价博客哦~',
									type: 'warning',
									center: true
								});
              } else {
								vm.$message({
									message: resp.data.message,
									type: 'error',
									center: true
								});
							}
						})
					}
        },
        created() {
            this.getComment()
            this.blogId = this.$route.params.id;
            this.getBlogDetails()
        }
    }
</script>
<style scoped lang="less">
    .site-content {
        position: relative;
        .site-main {
            padding: 80px 0 0 0;
        }
    }
    #article-menus{
        position: sticky;
        top: 0;
        box-shadow: 0 2px 6px rgba(0, 0, 0, .1);
        border-radius: 3px;
        padding: 15px;
        width: 300px;
        transform: translateX(-120%) translateY(150px);
        font-size: 14px;
    }
    article.hentry {
        .entry-header {
            .entry-title {
                font-size: 23px;
                font-weight: 600;
                color: #737373;
                margin: 0.67em 0;

                &:before {
                    content: "#";
                    margin-right: 6px;
                    color: #d82e16;
                    font-size: 20px;
                    font-weight: 600;
                }
            }

            hr {
                height: 1px;
                border: 0;
                background: #EFEFEF;
                margin: 15px 0;
            }

            .breadcrumbs {
                font-size: 14px;
                color: #D2D2D2;
                text-decoration: none;
                margin-bottom: 30px;
            }
        }

        .entry-content {}

        footer.post-footer {
            width: 100%;
            padding: 20px 10px;
            margin-top: 30px;
            height: 65px;
            position: relative;
            i{
                font-size: 18px;
                margin-right: 5px;
            }
            .post-like {
                float: right;
                margin: 7px 0 0 20px;
            }

            .post-share {
                float: right;
                list-style: none;
                margin-right: 20px;
            }

            .donate {
                float: left;
                line-height: 36px;
                border-radius: 100%;
                -webkit-border-radius: 100%;
                -moz-border-radius: 100%;
                border: 1px solid #2B2B2B;
                &:hover{
                    border: 1px solid goldenrod;
                    span{
                        color: goldenrod;
                    }
                }
                span {
                    color: #2B2B2B;
                    padding: 10px;
                    position: relative;
                    cursor: pointer;
                }

                .donate_inner {
                    display: none;
                    margin: 0;
                    list-style: none;
                    position: absolute;
                    left: 80px;
                    top: -40px;
                    background: #FFF;
                    padding: 10px;
                    border: 1px solid #ddd;
                    box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
                    border-radius: 3px;
                    &.show{
                        display: block;
                    }
                    li {
                        float: left;
                    }

                    img {
                        width: 100px;
                    }
                    p {
                        text-align: center;
                        font-size: 15px;
                        color: #D2D2D2;
                        line-height: 1rem;
                    }
                }

                .donate_inner:after, .donate_inner:before {
                    content: "";
                    position: absolute;
                    left: 0;
                    bottom: 45%;
                    margin-left: -8px;
                    border-top: 8px solid transparent;
                    border-bottom: 8px solid transparent;
                    border-right: 8px solid #fff;
                }

                .donate_inner:before {
                    left: -1px;
                    border-right: 8px solid #ddd;
                }

            }

            .post-tags {
                margin: 7px 0 0 20px;
                float: left;
                text-transform: uppercase;
                a:hover{
                    color: #ff6d6d;
                }
            }
        }
        .open-message {
            margin: 50px 0;
            position: relative;
            background: #2B2B2B;
            padding: 10px 30px;
            border-radius: 3px;
            font-size: 14px;
            color: #fff;
            &:after {
                content: "";
                border-left: 10px solid transparent;
                border-right: 10px solid transparent;
                border-bottom: 10px solid #2B2B2B;
                position: absolute;
                top: -8px;
                left: 48%;
            }
            p {
                margin: 10px 0;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }
            a {
                color: #A0DAD0;
                padding: 0 5px;
            }
        }
    }
</style>
